package whf.framework.workflow.assign.parser;

import java.util.Collection;
import java.util.Set;

import org.jdom.Element;

import whf.framework.exception.AppException;
import whf.framework.exception.FindException;
import whf.framework.workflow.assign.AssignmentService;

/**
 * @author king
 *
 */
public class HqlAssignmentParser extends DefaultAssignmentParser implements RoleableAssignmentParser, DeptableAssignmentParser {
	private String hql;
	
	private Collection<String> deptCodes;
	
	private String roleName;
	
	public Collection<String> getDeptCodes() {
		return deptCodes;
	}

	public void setDeptCodes(Collection<String> deptCodes) {
		this.deptCodes = deptCodes;
	}

	public String getRoleName() {
		return roleName;
	}

	public void setRoleName(String roleName) {
		this.roleName = roleName;
	}

	@Override
	protected void parseSourceElement(Element source) throws AppException {
		this.hql = super.getText();
	}

	public Collection<String> getUsers() throws FindException {
		return AssignmentService.getAssignmentService().findUsersByHql(this.deptCodes, this.roleName, this.hql);
	}

	public Set<AssignmentParser> getChildrenParsers() {
		return null;
	}

}
